﻿<%@ Page Language="C#" %>
<%@ Import Namespace="System.Collections.Generic" %>
<%@ Register src="~/App_Control/Dashboard.ascx" tagname="Dashboard" tagprefix="uc" %>
<%@ Register src="~/App_Control/Alerts.ascx" tagname="Alerts" tagprefix="uc" %>
<%@ Register src="~/App_Control/Tabs.ascx" tagname="Tabs" tagprefix="uc" %>

<fb:title>Select Albums</fb:title>
<uc:Dashboard ID="d" runat="server" />
<uc:Alerts ID="a" runat="server" />
<uc:Tabs ID="t" runat="server" />

<style>
.filterandsearch
{
    background-color: #f7f7f7;
    background-image: none;
    background-repeat: repeat;
    background-attachment: scroll;
    background-x-position: 0%;
    background-y-position: 0%;
    padding-top: 5px;
    padding-right: 20px;
    padding-bottom: 4px;
    padding-left: 20px;
    border-bottom-width: 1px;
    border-bottom-style: solid;
    border-bottom-color: #cccccc;
}
.searchwithin 
{
    display:inline;
    float:right;
    padding-top:3px;
    text-align:right;
    width:auto;
}
.albums
{
	background: #F7F7F7 none repeat scroll 0%;
	magin: 0px;
	padding: 10px 10px 5px;
}
.album
{
	background: white none repeat scroll 0%;
	border: 1px solid #CCCCCC;
	margin: 0px 0px 5px;
	padding: 9px;
}
.album .info
{
	vertical-align: top;
	width: 496px;
}
.album .actions
{
	vertical-align: top;
	width: 100px;
}
.album .label 
{
	color: Gray;
	width: 70px;
}
.album .name
{
	font-size: 13px;
	font-weight: bold;
}
.album .actions a:hover
{
	background: #3B5998 none repeat scroll 0%;
    color: white;
    text-decoration: none;
}
.album .actions a
{
    border-bottom: 1px solid #D8DFEA;
    display: block;
    margin: 0px;
    padding: 2px 4px;
}

</style>

<div class="filterandsearch clearfix">
    <div class="searchwithin">
        <form method="post">
            <input id="k" name="k" class="inputtext inputsearch" type="search" value='<%=KeywordParameter%>' />
            <input class="inputsubmit" type="submit" value="Search" />
        </form>
    </div>
    <table class="formtable" border="0" cellspacing="0">
        <tbody>
            <tr>
                <td class="label">Category:</td>
                <td>
                    <asp:ListView ID="lvCategories" runat="server">
                        <LayoutTemplate>
                            <form method="post">
                                <select id="c" name="c">
                                    <option value="0">-- All Categories --</option>
                                    <asp:PlaceHolder ID="itemContainer" runat="server" />
                                </select>
                                <input class="inputsubmit" type="submit" value="Filter" />
                            </form>
                        </LayoutTemplate>
                        <ItemTemplate>
                            <option <%#Eval("Selected")%> value='<%#Eval("ID")%>'><%#Eval("Title")%> (<%#Eval("AlbumCount")%> Albums)</option>
                        </ItemTemplate>
                    </asp:ListView>
                </td>
            </tr>
        </tbody>
    </table>
</div>
<div class="bar clearfix summary_bar">
    <div class="summary">
        <h4>Found 
            <asp:Literal ID="litAlbumTotalCount" runat="server" /> 
            albums 
            <asp:Literal ID="litFilterDescription" runat="server" />.</h4>
    </div>
</div>
<asp:ListView ID="lvAlbums" runat="server">
    <LayoutTemplate>
        <div class="albums"><asp:PlaceHolder ID="itemContainer" runat="server" /></div>
    </LayoutTemplate>
    <ItemTemplate>
        <div class="album">
            <table cellpadding="0" border="0">
                <tbody>
                    <tr>
                        <td class="image"></td>
                        <td class="info">
                            <table cellpadding="0" cellspacing="0" border="0">
                                <tbody>
                                    <tr>
                                        <td class="label">Title:</td>
                                        <td class="name"><%#Eval("Title")%></td>
                                    </tr>      
                                    <tr>
                                        <td class="label">Category:</td>
                                        <td><%#Eval("CategoryName")%></td>
                                    </tr>                              
                                </tbody>
                            </table>
                        </td>
                        <td class="actions">
                            <asp:HyperLink ID="hla" runat="server" Text="Add to My Profile"
                                NavigateUrl='<%#Eval("ID", "/smugmug_on_facebook/featured_albums/choose_photo/?a={0}")%>' />
                            <asp:HyperLink ID="hlv" runat="server" Text="View Album" 
                                NavigateUrl='<%#Eval("ID", "/smugmug_on_facebook/view_album/?a={0}")%>' />
                        </td>
                    </tr>
                </tbody>
            </table>        
        </div>
    </ItemTemplate>
</asp:ListView>

<form runat="server" id="f">
    <asp:GridView ID="gvCategories" runat="server" />
    

</form>

<script runat="server">
protected override void OnLoad(EventArgs e) 
{
    SmfbService smfb = new SmfbService();
    // Get a list of categories and bind to the dropdown.
    System.Collections.Generic.List<Category> categories = smfb.GetUsedCategories();
    this.lvCategories.DataSource = categories;
    this.lvCategories.DataBind();
    // Get a list of albums and bind to the album list.
    System.Collections.Generic.List<Album> albums = smfb.FindAlbums();
    this.lvAlbums.DataSource = albums;
    this.lvAlbums.DataBind();
    this.litAlbumTotalCount.Text = albums.Count.ToString();
    this.litFilterDescription.Text = smfb.GetAlbumFilterDescription();
}
public String KeywordParameter { get { return new SmfbService().KeywordParameter; } }
</script>